﻿using IMark.DAO;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IMark.UC
{
    public partial class TopMenuCtrl : System.Web.UI.UserControl
    {
        protected void Page_PreRender(object sender, EventArgs e)
        {
            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if(Session["Cart"]!=null)
                {
                    Dictionary<long, SAN_PHAM> Cart = Session["Cart"] as Dictionary<long, SAN_PHAM>;
                    if (Cart.Count > 0)
                    {
                        ThongTinDatHang.InnerHtml = SanPhamModels.GenerateCartInfo(Cart);
                        TongSP.InnerHtml = Cart.Count().ToString() + " Sản Phẩm";
                        long TongThanhTien = SanPhamModels.TongThanhTienGioHang(Cart);
                        TongTien.InnerHtml = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", TongThanhTien) + " VNĐ";
                        TongTien2.InnerHtml = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", TongThanhTien) + " VNĐ";

                    }
                }
                
            }
        }
    }
}